package net.hxz.modules.services.impl;

import java.security.NoSuchAlgorithmException;

import net.hxz.modules.pojo.BackEndUser;
import net.hxz.modules.services.IUserService;
import net.wy.commons.util.DigestUtil;

import org.springframework.stereotype.Service;

@Service("userService")
public class UserService implements IUserService {
	
	public BackEndUser getBackEndUser(BackEndUser root) {
		if (root == null) {
			return null;
		}
		if( !root.getName().equals(BackEndUser.Default.name) ){
			return null;
		}
		try {
			String password = DigestUtil.digestString(root.getPassword(), "SHA");
			if (BackEndUser.Default.password.equals(password)) {
				return root;
			}
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}

}
